(function() {

	Path.on("/__basename__.html", function(_current_location) {
		var queryString = _current_location.query;
		var classify_id = queryString.get("id");
		App.set("$Cache.classify_goods_list.classify_id", classify_id);
		var goods_id = queryString.get("goods_id");
		App.set("$Cache.classify_goods_list.goods_id", goods_id);
		if (!classify_id) {
			myConfirm("分类不存在！！！");
			Path.jump("/main.html");
			return;
		};
		if (App.get("$Cache.classify_goods_list.scroll_position")) {
			document.body.scrollTop = App.get("$Cache.classify_goods_list.scroll_position");
		};
		// 加载该分类的上下级联
		coAjax.get(appConfig.bus_classify_by_id + classify_id, {
			bus_id: busInfo._id
		}, function(classify_detail) {
			App.set("$Cache.classify_goods_list.classify_detail", classify_detail.result);
		});

		// 加载选定分类下的商品
		App.set("$Cache.classify_goods_list.is_loading", false);
		coAjax.get(appConfig.bus_classify_all_child_goods_by_id + (goods_id || classify_id), {
			bus_id: busInfo._id
		}, function(goods_list) {
			App.set("$Cache.classify_goods_list.goods_list", goods_list.result);
			App.set("$Cache.classify_goods_list.is_loading", true);
		});

	});

	App.set("$Event.classify_goods_list.jump_to_details", function(e, vm) {
		App.set("$Cache.classify_goods_list.scroll_position", document.body.scrollTop);
		Path.jump("/goods_details.html?id=" + vm.get("_id"));
	});

}());